import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component:()=> import('@/views/List.vue'),
      meta:{title:'首页列表'}
    },
    {
      path: '/stuaddoredit',
      component: () => import('@/views/AddorEdit.vue'),
      meta:{title:'新增'}
    },
    {
      path: '/stuaddoredit/:id',
      component: () => import('@/views/AddorEdit.vue'),
      meta:{title:'编辑'}
    }
  ],
})

router.beforeEach((to,next)=>{
  if(to.path && to.meta.title){
    document.title=to.meta.title
  }
  else{
    next()
  }
})
export default router
